package com.itheima.controller;

import com.itheima.R;
import com.itheima.dto.returnReason;
import com.itheima.dto.returnReasonDto;
import com.itheima.service.OmsOrderReturnService;
import com.itheima.vo.MinioVo;
import com.itheima.vo.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 芝士雪豹
 * @create 2022/10/15/17:17
 */
@RestController
@RequestMapping("/returnReason")
public class OmsOrderReturnController {
    @Autowired
    private OmsOrderReturnService service;

    //添加退货原因
    @PostMapping("/create")
    public MinioVo create(@RequestBody returnReasonDto dto) {
        MinioVo vo = service.create(dto);
        return vo;
    }

    //批量删除退货原因
    @PostMapping("/delete")
    public MinioVo delete(@RequestBody Integer[] ids) {
        MinioVo vo = service.delete(ids);
        return vo;
    }

    //分页查询退货原因
    @GetMapping("/list")
    public R list(@RequestBody Integer pageSize, Integer pageNum) {
        PageResult vo = service.list(pageNum, pageSize);
        return R.success(vo);
    }

    //修改退货原因启用状态
    @PostMapping("/update/status")
    public MinioVo updateStatus(@RequestBody Integer[] ids, Integer status) {
        MinioVo vo = service.updateStatus(ids, status);
        return vo;
    }

    //修改退货原因
    @PostMapping("/update/{id}")
    public MinioVo updateById(@PathVariable Integer id, @RequestBody returnReason dto) {
        MinioVo vo = service.updateById(id, dto);
        return vo;
    }

    //获取单个退货原因详情信息
    @GetMapping("/{id}")
    public MinioVo findOne(@PathVariable Integer id) {
        MinioVo vo = service.findOne(id);
        return vo;
    }

}
